Skip to content

STMicro Nucleo-F401re: implemented comprehensive ThreadX RTOS monitor and primitives showcase#45

Merged
fdesbiens merged 14 commits into
eclipse-threadx:devfrom
AmmarOkla12772:feat/clean-nucleo-demo
Jul 20, 2026
Merged

STMicro Nucleo-F401re: implemented comprehensive ThreadX RTOS monitor and primitives showcase#45
fdesbiens merged 14 commits into
eclipse-threadx:devfrom
AmmarOkla12772:feat/clean-nucleo-demo

Conversation

@AmmarOkla12772

Copy link
Copy Markdown
Contributor

Note: This PR supersedes the previous submission having addressed the review feedback. The AZ3166 refactoring has been undone, and the required MIT license header has been added to main.c.

Overview

This PR extends the validation demo for the STMicroelectronics NUCLEO-F401RE board under STMicroelectronics/NUCLEO_F401RE/.

The goal is to provide a comprehensive ThreadX RTOS demonstration showcasing dynamic memory management, runtime diagnostics, thread monitoring, and synchronization primitives using public ThreadX APIs.

Changes

  • Replaced static thread stack allocation with a central TX_BYTE_POOL
  • Added runtime memory diagnostics reporting total, allocated, and free byte pool capacity
  • Added TX_BLOCK_POOL for fixed-size deterministic memory allocation
  • Added message passing between sender and receiver threads using TX_QUEUE
  • Added pointer-based queue transfers backed by block pool allocations
  • Added TX_MUTEX synchronization with two competing worker threads sharing a simulated SPI resource
  • Added TX_EVENT_FLAGS_GROUP synchronization between the LED heartbeat thread and an event-processing thread
  • Added TX_SEMAPHORE synchronization with a dedicated consumer thread awakened by LED activity
  • Added TX_TIMER periodic callback executing once per second from the ThreadX system timer thread
  • Expanded the demo from 3 threads to 9 threads to exercise core ThreadX scheduling and synchronization features
  • Added registry-based thread diagnostics using tx_thread_info_get()
  • Added stack high-water mark monitoring by scanning the ThreadX stack fill pattern (0xEFEFEFEF)
  • Added per-thread stack usage and utilization reporting
  • Added formatted runtime telemetry output over USART2 including thread states, priorities, run counts, memory statistics, and synchronization activity counters
  • Added the required MIT license header to main.c to align with project licensing requirements.

Validation

Tested on physical NUCLEO-F401RE board:

  • System runs continuously without crashes or scheduler instability
  • UART output remains stable at 115200 baud
  • Free memory remains constant at 79028 bytes during operation, indicating no byte pool or block pool leaks
  • Thread diagnostics correctly report state transitions, run counts, priorities, and stack watermarks
  • Stack utilization remains within safe limits for all threads
  • System uptime tracks wall-clock time accurately
  • ThreadX synchronization primitives operate as expected under active scheduling
  • No build warnings with Arm GNU Toolchain 15.2.Rel1

Toolchain

  • Arm GNU Toolchain 15.2.Rel1
  • CMake + Ninja build system

Notes

All runtime diagnostics are implemented using documented ThreadX public APIs. No private kernel structures or undocumented internal ThreadX data are accessed, maintaining portability across ThreadX targets.

ammarokla123 and others added 14 commits June 8, 2026 05:10
	new file:   STMicroelectronics/NUCLEO_F401RE/README.md
	new file:   STMicroelectronics/NUCLEO_F401RE/app/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/board_init.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/board_init.h
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/console.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/sntp_client.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/NUCLEO_F401RE.ld
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/startup_stm32f401xe.s
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/tx_initialize_low_level.S
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/stm32cubef4/stm32f4xx_hal_msp.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/starter/cloud_config.h
	new file:   STMicroelectronics/NUCLEO_F401RE/app/starter/main.c
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/FindCMSIS.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/FindSTM32HAL.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/arm-gcc-cortex-m4.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/arm-gcc-cortex-toolchain.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/utilities.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/nucleo_bsp.c
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/nucleo_bsp.h
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/stm32cubef4/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/stm32cubef4/config/stm32f4xx_hal_conf.h
Booted ThreadX on NUCLEO-F401RE
Validated scheduler operation
Validated UART console output
Validated LED thread
Validated flashing and hardware execution
…and event flags. Modified demo README file to reflect changes.
…aphore functionality and 1 hz applicaion timer.
Co-authored-by: Codex <codex@openai.com>
Retained the PR implementation for overlapping NUCLEO-F401RE files.\n\nCo-authored-by: Codex <codex@openai.com>
@fdesbiens fdesbiens changed the title feat(nucleo-f401re): implement comprehensive ThreadX RTOS monitor and primitives showcase STMicro Nucleo-F401re: implemented comprehensive ThreadX RTOS monitor and primitives showcase Jul 20, 2026
@fdesbiens
fdesbiens merged commit 1bddd17 into eclipse-threadx:dev Jul 20, 2026
1 check passed
@fdesbiens

Copy link
Copy Markdown
Contributor

I merged to dev; this will ship with the Q3 2026 release in September.

Thank you for this contribution, @AmmarOkla12772.

In the future, make sure your original files contain the full mandatory header as shown below.

/*
 * Copyright (c) 2026 Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available
 * under the terms of the MIT license which is available at
 * https://opensource.org/license/mit.
 *
 * SPDX-License-Identifier: MIT
 */

Also, there were some minor merge conflicts. Always make sure you pull from upstream before creating a PR. Don't worry, I forget this from time to time myself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants